﻿using System;

namespace diantou.web.ajax.admin
{
    /// <summary>
    /// 教程调用
    /// </summary>
    [fastCSharp.code.cSharp.ajax(IsPool = true)]
    class tutorial : permissionHandle<tutorial>
    {
        /// <summary>
        /// 添加教程
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void Append(diantou.dataAccess.tutorial value, Action<fastCSharp.net.returnValue<int>> onReturn)
        {
            if ((currentUser.Permission & dataModel.user.permission.TutorialEditor) != 0)
            {
                value.UserId = currentUser.Id;
                diantou.dataAccess.tcpCall.tutorial.append(value, onReturn);
            }
            else onReturn(0);
        }
        /// <summary>
        /// 修改教程
        /// </summary>
        /// <param name="value"></param>
        /// <param name="onReturn"></param>
        public void Rework(diantou.dataAccess.tutorial value, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            if ((currentUser.Permission & dataModel.user.permission.TutorialEditor) != 0) diantou.dataAccess.tcpCall.tutorial.rework(value, currentUser.Id, onReturn);
            else onReturn(false);
        }
        /// <summary>
        /// 删除教程
        /// </summary>
        /// <param name="id"></param>
        /// <param name="onReturn"></param>
        public void Delete(int id, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            if (currentUser.Permission == dataModel.user.permission.Admin) diantou.dataAccess.tcpCall.tutorial.delete(id, onReturn);
            else onReturn(false);
        }
        /// <summary>
        /// 添加基础教程
        /// </summary>
        /// <param name="id"></param>
        /// <param name="baseId"></param>
        /// <param name="onReturn"></param>
        public void AppendBase(int id, int baseId, Action<fastCSharp.net.returnValue<string>> onReturn)
        {
            if ((currentUser.Permission & dataModel.user.permission.TutorialEditor) != 0) diantou.dataAccess.tcpCall.tutorial.appendBase(id, baseId, currentUser.Id, onReturn);
            else onReturn(null);
        }
        /// <summary>
        /// 删除基础教程
        /// </summary>
        /// <param name="id"></param>
        /// <param name="baseId"></param>
        /// <param name="onReturn"></param>
        public void DeleteBase(int id, int baseId, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            if ((currentUser.Permission & dataModel.user.permission.TutorialEditor) != 0) diantou.dataAccess.tcpCall.tutorial.deleteBase(id, baseId, currentUser.Id, onReturn);
            else onReturn(false);
        }
        /// <summary>
        /// 添加提高教程
        /// </summary>
        /// <param name="id"></param>
        /// <param name="upId"></param>
        /// <param name="onReturn"></param>
        public void AppendUp(int id, int upId, Action<fastCSharp.net.returnValue<string>> onReturn)
        {
            if ((currentUser.Permission & dataModel.user.permission.TutorialEditor) != 0) diantou.dataAccess.tcpCall.tutorial.appendUp(id, upId, currentUser.Id, onReturn);
            else onReturn(null);
        }
        /// <summary>
        /// 删除提高教程
        /// </summary>
        /// <param name="id"></param>
        /// <param name="upId"></param>
        /// <param name="onReturn"></param>
        public void DeleteUp(int id, int upId, Action<fastCSharp.net.returnValue<bool>> onReturn)
        {
            if ((currentUser.Permission & dataModel.user.permission.TutorialEditor) != 0) diantou.dataAccess.tcpCall.tutorial.deleteUp(id, upId, currentUser.Id, onReturn);
            else onReturn(false);
        }
    }
}
